﻿<Page x:Class="App39.Views.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:Behaviors="using:App39.Behaviors"
      xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:designtime="using:App39.Designtime"
      xmlns:local="using:App39.Views"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:prism="using:Microsoft.Practices.Prism.Mvvm"
      prism:ViewModelLocator.AutoWireViewModel="True"
      mc:Ignorable="d">

    <d:Page.DataContext>
        <designtime:MainPageViewModel />
    </d:Page.DataContext>

    <Hub Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Header="Social TextBox Behavior">
        <HubSection>
            <DataTemplate>
                <StackPanel>
                    <TextBox Text="{Binding Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                        <Interactivity:Interaction.Behaviors>
                            <Behaviors:SocialTextBoxBehavior x:Name="TwitterBehavior" />
                        </Interactivity:Interaction.Behaviors>
                    </TextBox>
                    <TextBlock Margin="0,10" DataContext="{Binding ElementName=TwitterBehavior}">
                        <Run Text="{Binding CurrentLength}" />
                        <Run Text="character(s) typed." />
                        <LineBreak />
                        <Run Text="{Binding RemainingLength}" />
                        <Run Text="character(s) remaining." />
                        <LineBreak />
                        <Run Text="{Binding MaxLength}" />
                        <Run Text="character(s) limit." />
                        <LineBreak />
                        <Run Text="Can submit? " />
                        <Run Text="{Binding IsValid}" />
                    </TextBlock>
                    <Button IsEnabled="{Binding IsValid, ElementName=TwitterBehavior}" />
                </StackPanel>
            </DataTemplate>
        </HubSection>
    </Hub>
</Page>
